package com.example.pt.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;

import java.sql.Date;

@Entity
@TableName("user")
public class User {
    @Id
    @TableId(value = "uid", type = IdType.AUTO)
    private int uid;

    private String username;

    private String password;
    private String email;
    private String headshot;

    //0是管理员 ，1是用户
    private int usertype;
    private int points;
    private int level;

    @Column(name = "register_date")
    private Date registerDate;

    @Column(name = "last_login_time")
    private Date lastTime;
    
    // 用户状态：0-正常，1-被封禁，2-下载分享不符合规范
    private Integer status;

    //首次违规时间，缓冲期为1周7天
    @Column(name = "buffer_day")
    private Date bufferDay;

    public int getUid() {
        return uid;
    }
    public void setUid(int uid) {
        this.uid = uid;
    }
    public void setLevel(int level) {
        this.level = level;
    }
    public int getLevel() {
        return level;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getHeadshot() {
        return headshot;
    }
    public void setHeadshot(String headshot) {
        this.headshot = headshot;
    }
    public int getUsertype() {
        return usertype;
    }
    public void setUsertype(int usertype) {
        this.usertype = usertype;
    }
    public int getPoints() {
        return points;
    }
    public void setPoints(int points) {
        this.points = points;
    }
    
    public Integer getStatus() {
        return status;
    }
    
    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getRegisterDate() {
        return registerDate;
    }
    public void setRegisterDate(Date registerDate) {
    this.registerDate = registerDate;
    }
    public Date getLastTime() {
        return lastTime;
    }
    public void setLastTime(Date lastTime) {
        this.lastTime = lastTime;
    }
    public void setBufferDay (Date bufferDay) {
        this.bufferDay = bufferDay;
    }
    public Date getBufferDay() {
        return bufferDay;
    }
    /**
     * 判断用户是否已注销
     * @return 是否注销
     */
    public boolean isDeactivated() {
        return status != null && status == 1;
    }
}
